package com.zoe.app.config;

import cn.hutool.core.date.DateUtil;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author Zoe.Zhang
 * @date 2021/10/11
 * @description
 */
@Configuration
public class JacksonConfig {
    @Bean
    Jackson2ObjectMapperBuilderCustomizer jackson2ObjectMapperBuilderCustomizer() {
        return (x) -> {
            x.dateFormat(DateUtil.newSimpleFormat("yyyy-MM-dd HH:mm:ss"));
            x.serializerByType(Long.class, ToStringSerializer.instance);
        };
    }
}
